<!--
 * @Date: 2024-12-06 15:58:04
 * @Author: LiSong
 * @LastEditors: LiSong
 * @LastEditTime: 2025-02-26 14:21:48
 * @Description: 主页渲染
-->
<template>
  <LayoutFull :="layoutAttrs">
    <template #header_left>
      <el-select
        v-model="homeState.homeCode"
        clearable
        placeholder="请选择需要渲染的主页"
      >
        <el-option-group label="启用">
          <el-option
            v-for="item in homeState.homePages.filter(item => item.status === 1)"
            :key="item.formId"
            :label="item.name"
            :value="item.code"
          >
          </el-option>
        </el-option-group>
        <el-option-group label='停用'>
          <el-option
            v-for="item in homeState.homePages.filter(item => item.status === 0)"
            :key="item.formId"
            :label="item.name"
            :value="item.code"
          >
          </el-option>
        </el-option-group>
      </el-select>
    </template>
    <template #header_right>
    </template>
    <template #main>
      <el-scrollbar>
        <HpRender v-if="homeState.homeCode" :homeCode="homeState.homeCode"/>
      </el-scrollbar>
    </template>
  </LayoutFull>
</template>

<script setup>
import { HpRender } from '@hp'
import { reactive } from 'vue';
import { defAxios as request } from '@/utils/http'

const layoutAttrs = reactive({
  enableAside: false,
  enableHeader: true,
  openUpDownMain: false,
})

const homeState = reactive({
  loading: false,
  homeCode: '',
  homePages: []
})
const loadHomePages = async () => {
  homeState.loading = true
  const res = await reqGetHomePages()
  homeState.homePages = res.data
  homeState.loading = false
  console.log(res)
}
const reqGetHomePages = () => {
  return request({
    url: '/prdFormInfo/queryPrdFormInfoList',
    method: 'POST',
    data: {},
  });
}

loadHomePages()

</script>

<style lang="scss" scoped>

</style>